package it.valeandre.omino.model;

import java.util.ArrayList;
import java.util.List;

import android.util.Pair;

import it.valeandre.omino.utils.TypedPair;

public class EventDetails {

    private TypedPair.MatchType mMatchType;
    private TypedPair.EventType mEventType;
	
	public EventDetails(String eventDetailString, TypedPair.MatchType matchType, TypedPair.EventType eventType) {
		this.eventDetailString = eventDetailString;
        mMatchType = matchType;
        mEventType = eventType;
	}

	private String eventDetailString;
	
	private List<TypedPair<String, String>> eventDetailPairList;

	public List<TypedPair<String, String>> getEventDetailPairList() {
		eventDetailPairList = new ArrayList<TypedPair<String,String>>();
		try {
            if (eventDetailString != null) {
                String[] events = eventDetailString.split(";");
                for (String event : events) {
                    String minute = event.split(":")[0];
                    String author = event.split(":")[1];
                    TypedPair<String, String> eventPair = new TypedPair<String, String>(minute.trim(), author.trim());
                    eventPair.setMatchType(mMatchType);
                    eventPair.setEventType(mEventType);
                    eventDetailPairList.add(eventPair);
                }
            }
        } catch (IndexOutOfBoundsException ex) {
            return new ArrayList<TypedPair<String, String>>();
        }

		return eventDetailPairList;
	}

}
